//
//  YTUserLoginAPI.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/5/5.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTUserLoginAPI.h"

@implementation YTUserLoginAPI

+ (RACSignal *)userLogin:(NSString *)phoneNum
                password:(NSString *)password
                areaCode:(NSString *)areaCode {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[@"mobile"] = phoneNum;
    dict[@"password"] = password;
    dict[@"areaCode"] = areaCode;
    return [[self requestWithURL:@"user/userLogin" paramters:dict] replayLazily];
}

+ (RACSignal *)sendVerifyCode:(NSString *)phoneNum areaCode:(NSString *)areaCode {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[@"areaCode"] = areaCode;
    dict[@"mobile"] = phoneNum;
    return [self requestWithURL:@"commons/getMobileCode" paramters:dict];
}

+ (RACSignal *)validateVerifyCode:(NSString *)code
                         phoneNum:(NSString *)phoneNum
                         areaCode:(NSString *)areaCode {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[@"areaCode"] = areaCode;
    dict[@"mobile"] = phoneNum;
    dict[@"mobileCode"] = code;
    return [self requestWithURL:@"commons/verifyMobileCode" paramters:dict];
}

+ (RACSignal *)registerWithPhoneNum:(NSString *)phoneNum
                           areaCode:(NSString *)areaCode
                           password:(NSString *)password
                         verifyCode:(NSString *)verifyCode
                         inviteCode:(NSString *)inviteCode
                             inLand:(NSString *)isInLand {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[@"areaCode"] = areaCode;
    dict[@"mobile"] = phoneNum;
    dict[@"mobileCode"] = verifyCode;
    dict[@"password"] = password;
    dict[@"isChina"] = isInLand;
    if (![inviteCode isEqualToString:@""]) {
        dict[@"inviteCode"] = inviteCode;
    }
    return [self requestWithURL:@"user/userRegister" paramters:dict];
}

+ (RACSignal *)userFindPassWordWithPhone:(NSString *)phoneNum
                                areaCode:(NSString *)areaCode
                              verfiyCode:(NSString *)verfiyCode
                                password:(NSString *)password {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[@"mobile"] = phoneNum;
    dict[@"areaCode"] = areaCode;
    dict[@"mobileCode"] = verfiyCode;
    dict[@"newPassword"] = password;
    return [self requestWithURL:@"user/userForgetPassword" paramters:dict];
}

+ (RACSignal *)userLogout {
    return [[self requestWithURL:@"user/userLogout" paramters:nil] replayLazily];
}

@end
